home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_weap_pistol.cog < prev    next >
Text File  |  1999-11-15  |  4KB  |  209 lines

  1. # Jones 3D Cog Script
  2. #
  3. # weap_Pistol.cog
  4. #
  5. # This COG controls Indy's 1917 Smith & Wesson revolver.  It's always with Indy (except on
  6. # the SEA level), never runs out of ammo, and stays crunchy in milk.
  7. #
  8. # [RandyT]
  9. #
  10. # (C) 1998 LucasArts Entertainment Company LLC. All Rights Reserved
  11. #
  12. # ===================================================================
  13.  
  14. symbols
  15.  
  16. message        startup
  17. message        fire
  18. message        aim
  19. message        activated
  20. message        deactivated
  21. message        selected
  22. message        deselected
  23. message        callback
  24.  
  25. sound        bang=gen_pistol_fire.wav    local    # Autoloaded
  26. sound        pull=gen_pistol_pull.wav    local    # Autoloaded
  27. sound        put=gen_pistol_put.wav        local    # Autoloaded
  28.  
  29. template    projectile=+pistol            local    # Autoloaded
  30. template    smoke1=+pistol_smoke1        local    # Autoloaded
  31. template    smoke2=+pistol_smoke2        local    # Autoloaded
  32.  
  33. thing        player                        local
  34. thing        bullet                        local
  35.  
  36. flex        aimFOV=10.0                    local
  37. flex        aimMax=90.0                    local
  38. flex        aimWait=0.2                    local
  39. flex        fireWait=0.52                local
  40.  
  41. int            handNode                    local
  42. int            holsterMesh                    local
  43. int            weaponNum=3                    local
  44. int            callNum                        local
  45.  
  46. int            bJacketIndy=0                local
  47. int            bActivated=0                local
  48.  
  49. vector        firePos                        local
  50.  
  51. end
  52.  
  53. # ===================================================================
  54.  
  55. code
  56.  
  57. startup:
  58.  
  59.     player = GetLocalPlayerThing();
  60.     handNode = GetNodeByName(player, "inrhand");
  61.  
  62.     # Indy is wearing the Colt 45 by default, but ONLY if he's in his shirt
  63.     bJacketIndy = IsThingModelName(player, "gen_in.3do");
  64.  
  65.     if (!bJacketIndy)
  66.     {
  67.         holsterMesh = GetMeshByName(player, "inholster");
  68.         LoadHolsterModel(weaponNum, "holster_in_revolver.3do");
  69.         
  70.         if (GetLastPistol(player) == weaponNum)
  71.         {
  72.             SetHolsterModel(player, weaponNum, holsterMesh);
  73.         }
  74.     }
  75.  
  76.     return;
  77.  
  78. # -------------------------------------------------------------------
  79.  
  80. fire:
  81.  
  82.     # Fire away...
  83.     firePos = GetThingJointPos(player, handNode);
  84.     bullet = FireProjectile(player, projectile, bang, 65, firePos, '3.0 -6.5 0.0', 1.0, 0x2a0, aimFOV, aimMax);
  85.  
  86.     if (Rand() < 0.5) CreateThing(smoke1, bullet);
  87.     else CreateThing(smoke2, bullet);
  88.  
  89.     SetFireWait(player, fireWait);
  90.  
  91.     return;
  92.  
  93. # -------------------------------------------------------------------
  94.  
  95. aim:
  96.  
  97.     if (GetParam(0))
  98.     {
  99.         if (!IsAiming(player) && !bActivated)
  100.         {
  101.             while ((PlayMode(player, 63, 0) == -99) && (!bActivated))
  102.             {
  103.                 Sleep(0.01);
  104.             }
  105.         }
  106.     }
  107.     else if (IsModePlaying(player, 63) && !bActivated)
  108.     {
  109.         SetAimWait(player, aimWait);
  110.         StopMode(player, 63, aimWait);
  111.     }
  112.  
  113.     return;    
  114.  
  115. # -------------------------------------------------------------------
  116.  
  117. activated:
  118.  
  119.     bActivated = 1;
  120.     SetAimWait(player, aimWait);
  121.  
  122.     if (!IsAiming(player))
  123.     {
  124.         while (PlayMode(player, 63, 0) == -99)
  125.         {
  126.             Sleep(0.01);
  127.         }
  128.     }
  129.  
  130.     ActivateWeapon(player, aimWait);
  131.  
  132.     return;
  133.  
  134. # -------------------------------------------------------------------
  135.  
  136. deactivated:
  137.  
  138.     bActivated = 0;
  139.  
  140.     if (!IsAiming(player))
  141.     {
  142.         SetAimWait(player, aimWait);
  143.         StopMode(player, 63, aimWait);
  144.     }
  145.  
  146.     DeactivateWeapon(player);
  147.  
  148.     return;
  149.  
  150. # -------------------------------------------------------------------
  151.  
  152. selected:
  153.  
  154.     SetMountWait(player, 0.7);
  155.  
  156.     SetArmedMode(player, 2);
  157.     SetCurWeapon(player, weaponNum);
  158.     SetThingFireOffset(player, '0.06 0.015 0.002');
  159.  
  160.     CaptureThing(player);
  161.     PlayMode(player, 62, 0);
  162.  
  163.     return;
  164.  
  165. # -------------------------------------------------------------------
  166.  
  167. deselected:
  168.  
  169.     if (IsAiming(player))
  170.     {
  171.         SetAimWait(player, aimWait);
  172.         StopMode(player, 63, aimWait);
  173.     }
  174.  
  175.     SetMountWait(player, 1.07);
  176.  
  177.     StopMode(player, 62, 0);
  178.  
  179.     CaptureThing(player);
  180.     PlayMode(player, 64, 0);
  181.  
  182.     SetArmedMode(player, 0);
  183.  
  184.     return;
  185.  
  186. # -------------------------------------------------------------------
  187.  
  188. callback:
  189.  
  190.     callNum = GetParam(1);
  191.     ReleaseThing(player);
  192.  
  193.     if (callNum == 28)
  194.     {
  195.         if (!bJacketIndy) ResetHolsterModel(player, 2);
  196.         PlaySoundThing(pull, player, 1, -1, -1, 0x880);
  197.         SetWeaponModel(player, weaponNum);
  198.     }
  199.     else if (callNum == 29)
  200.     {
  201.         if (!bJacketIndy) SetHolsterModel(player, weaponNum, holsterMesh);
  202.         PlaySoundThing(put, player, 1, -1, -1, 0x880);
  203.         ResetWeaponModel(player);
  204.     }
  205.  
  206.     return;
  207.  
  208. end
  209.